<?php 

/**
 * NOTICE OF LICENSE
 *
 * THIS SOURCE FILE IS PART OF EVEBIT'S PRIVATE PROJECT.
 * 
 * DO NOT USE THIS FILE IN OTHER PLACE.
 *
 * @category    ChinaWanderer
 * @package     Blocks
 * @subpackage  Template
 * @author      Chen Qiao <chen.qiao@evebit.com>
 * @version     $$Id: form.phtml 1432 2011-06-27 08:15:42Z chen.hao $$
 * @copyright   Copyright (c) 2011 Evebit Inc. China (http://www.evebit.com)
 */

$formId = $this->form;
$acl=$this->acl;
$label = $this->label;
$returnUrl 	= $this->return_url;
$resetUrl	= $this->reset_url;	
$postUrl 	= $this->post_url;
$form_buttons= $this->form_buttons;
$checkUrl = $this->check_url;
$data = $this->data;
$frontHTML=$this->frontHTML;
$inputs = $this->inputs;
$fieldsets = $this->fieldsets;
$addSelect = $this->addSelect;
$selectType = $this->selectType;

if (is_array($data)) {
	$data = new Varien_Object($data);
} else if (!$data) {
	$data = new Varien_Object();
}
$icon="";
if($formId=="eventEditor"){
	$icon="18_48x48.png";
} else if($formId=="adminEditor"){
	$icon="16_48x48.png";
} else if($formId=="currency"||$formId=="translateEditor"||$formId=="translateAdd"){
	$icon="4_48x48.png";
}
?>


<div class="content-header" style="visibility: visible; text-align: left;">
    <table cellspacing="0">
       	<tr>
           	<td style="width: 50px;">
           	<?php if($icon!=""):?>
           	<img src="<?php echo $this->baseUrl('/media/assets/icons/'.$icon)?>" alt="" />
           	<?php endif;?> 
           	</td>
           	<td style="width: 50%;text-align:left;"><h1 style="float:left; padding-left: 20px" class="icon-head head-customer"><?php echo $label?></h1></td>
           	<td class="form-buttons" >
           		
           	</td>
       	</tr>
    </table>
</div>

<form id="<?php echo $formId?>" <?php echo @$this->customer ?>  method="post" action="<?php echo $postUrl?>" enctype="multipart/form-data" >
<fieldset>
<div style="width:190px;float:left;margin-bottom:5px;" class="meta">

<?php  if($returnUrl && !$addSelect):?>
<ul style="float:left;">
    <li>
	    <a onclick='checkForm()' style="width:60px;" class="tooltip" title="Save edit" href="#">
	    <span class="ui-icon ui-icon-document"></span>
		<?php echo $this->__('Save') ?></a></li>
	<li>
		<a onclick='location.href="<?php echo $returnUrl?>";' style="width:60px;" class="tooltip" title="Back to Admin Panel" href="#">
		<span class="ui-icon ui-icon-arrowthick-1-w"></span>
		<?php echo $this->__('Back') ?></a></li>
<?php endif;?>  
<?php if($addSelect) {?>
<ul style="float:left;width:395px;">
	<li>
		<a onclick='checkForm()' style="width:60px;" class="tooltip" title="Save edit" href="#">
		<span class="ui-icon ui-icon-document"></span>
		<?php echo $this->__('Save') ?></a></li>
	<li>
		<a onclick='location.href="<?php echo $returnUrl?>";' style="width:60px;" class="tooltip" title="Back to Admin Panel" href="#">
		<span class="ui-icon ui-icon-arrowthick-1-w"></span>
		<?php echo $this->__('Back') ?></a></li>
	
<?php } ?>  
<?php if($selectType) {?>
<input type="hidden" value="<?php echo $selectType;?>" name="data[info_type]"></input>
<?php }?>
<?php if($checkUrl):?>
	<ul style="float:left;width:265px;">
		<li><a onclick='location.href="<?php echo $checkUrl?>";' style="width:60px;" class="tooltip" title="Back to Admin Panel" href="#">
		<span class="ui-icon ui-icon-arrowthick-1-w"></span>
		<?php echo $this->__('Back') ?></a></li>
       <li><a onclick='checkInfo(1)' style="width:60px;" class="tooltip" title="Enable" href="#"><span class="ui-icon ui-icon-document"></span>
		<?php echo $this->__('Enable') ?></a></li>
		<li><a onclick='checkInfo(2)' style="width:60px;" class="tooltip" title="Disable" href="#"><span class="ui-icon ui-icon-document"></span>
		<?php echo $this->__('Disable') ?></a></li>
		
<?php endif;?> 
         
<?php if($resetUrl):?>
     <input type="button" class="button" onclick="setLocation('<?php echo $resetUrl?>')" vlaue='<?php echo $this->__('Reset') ?>'>
<?php endif;?>        		
           		<?php if($form_buttons):?>           			
	           		<?php foreach($form_buttons as $button):?>
	           			<button onclick="<?php echo @$button['onclick']?$button['onclick']:'setLocation('. $button['url'] . ')' ?>"
	           				class="scalable <?php echo $button['class'] ?>" type="button" >
	           				<span><?php echo $button['label'] ?></span>
	           			</button>
	           		<?php endforeach;?>
           		<?php endif;?>
           		</ul>
           		
</div>
<div style="clear:both;">
<?php if($frontHTML):?>
     <?php echo $frontHTML;?>
<?php endif;?> 
	<?php foreach ($inputs as $iid=>$input):?>
	<?php if ($input['type'] == 'hidden'):?>
   		<input type="hidden" id="data[<?php echo $iid?>]" name="data[<?php echo $iid?>]" value="<?php echo $data->getData($iid)?>" />
	<?php endif;?>
   	<?php endforeach;?>

	<?php foreach ($fieldsets as $fieldset):?>
	<div class="info_tabs_set_content">
		<div class="entry-edit">
			<div class="entry-edit-head">
				
				<div class="form-buttons"></div>
			</div>
		    <div id="settings" class="fieldset">
				<div class="hor-scroll">
				<table cellspacing="0" class="form-list">
				<?php foreach ($fieldset['inputs'] as $iid=>$input):?>
					<tr>
		        		<td class="label"><label for="data-<?php echo $iid?>"><?php echo $input['label'] ?></label></td>
						<td class="value">
						<!-- TODO: ADD OTHER INPUT TYPE HERE -->
						<?php switch ($input['type']): case 'hidden': ?>
							<input type="hidden" name="data[<?php echo $iid?>]"
								id="data-<?php echo $iid?>" value="<?php echo $this->escape($data->getData($iid))?>" />
						<?php break;?>
						<?php case 'select':?>							
							<?php 								
								echo $this->formSelect("data[$iid]", (isset($input['value'])?$input['value']:$this->escape($data->getData($iid))),
									array(
										"class"=>"input-select " . (isset($input['class'])?$input['class']:''),									
									),$input['data']); 
								break;
								?>
						<?php case 'checkboxes':?>							
							<?php foreach ($input['data'] as $key=>$value):?>
							<?php $m++;?>
								<?php echo $value["label"];?> : <input type="checkbox" id="data[<?php echo $iid ?>][<?php echo $value["label"];?>]"  name="data[<?php echo $iid ?>][<?php echo $value["label"];?>]" value="1" />
							<?php if($m==4) echo "<br>";?>
								<?php endforeach;?>
								<script type="text/javascript">
								var values="<?php echo $data->getData($iid);?>".split("|");
								for(var i=0;i<values.length-1;i++)
									document.getElementById("data[<?php echo $iid ?>]["+values[i]+"]").checked="checked";
								</script>
						<?php break; ?>
						<?php case 'radio':?>
							<?php 
								echo $this->formRadio("data[$iid]",$this->escape($data->getData($iid)),
									'',$input['data'],'&nbsp;') ; 
								break;
								?>
						<?php case 'sponsored_poll':?>
							<?php if($data->getData('sponsored_poll')):?>
								<input type="checkbox" checked="checked" name="data[<?php echo $iid ?>]" value="1" />
							<?php else:?>
								<input type="checkbox" name="data[<?php echo $iid ?>]" value="1" />
							<?php endif;?>
							<?php break; ?>
						<?php case 'checkbox':?>
							<?php 
								$reated_over = '<br /><input style="margin-left:22px;" type="text" size="5" name="data[reated_over]" value="'.(($data->getData('reated_over')>0)?$data->getData('reated_over'):'1000').'" />';					
								foreach ($input['data'] as $checkbox_value=>$checkbox_caption): ?>
									<label>
										<input type="checkbox" name="data[<?php echo $iid ?>][]"
											 <?php echo in_array($checkbox_value,$data->getData('notify_by_email'))?'checked="checked"':'' ?>
											 value="<?php echo $checkbox_value?>" />
											 <?php if($iid == 'notify_by_email'):?>
											 <?php echo str_replace("1000",$reated_over,$checkbox_caption) ?>
											 <?php else: ?>
											 <?php echo $checkbox_caption; ?>
											 <?php endif;?>
									</label>
									<br />
							<?php 		
								endforeach;
								break;?>
						
						<?php case 'image':?>							
							<?php if($data->getThumbPath($iid,0,0,true)):	?>
							<img alt="" style="float:left;margin-right:5px;" width="20" height="20" src="<?php echo $this->baseUrl('/..'.$data->getThumbPath($iid,20,20)) ?>">	
							<?php endif; ?>		
							<?php echo $this->formFile($iid,
									array(
										"id"=>"data-".$iid,
										"class"=>"input-select".(isset($input['class'])?$input['class']:''),									
										)
									); 
								break;
							?>	
						<?php case 'upload_image':?>		
							<div id="original_pro" style="height: 0px;margin-top:15px;"></div>
							<div  style="text-align:left;"><img id="originalview" style="display:none;width:320px;" src="">
							<span id="original_pro_button"></span></div>
							<input type="hidden" id="data[<?php echo $iid?>]" name="data[<?php echo $iid?>]" value="<?php echo $data->getData($iid)?>" />
							<script>
							function swfInit(upload_target_id,imageId,button_text){
							var swfu = new SWFUpload({					
									upload_url: "<?php echo $this->baseUrl("/backend/IndexGallary/upload")?>",
									post_params: {"imageId": imageId},
									file_size_limit : "10 MB",
									file_types : "*.jpg;*.gif;*.png",
									file_types_description : "Images",
									file_upload_limit : "0",
									
									file_queue_error_handler : fileQueueError,
									file_dialog_complete_handler : fileDialogComplete,
									upload_progress_handler : uploadProgress,
									upload_error_handler : uploadError,
									upload_success_handler : function(file, serverData){ 
										if (!serverData) {
											$(imageId+"_thum").src = BASE_URL +"media/images/poll-content-image.png";
										} else {
											var dataObj=eval("("+serverData+")");
											document.getElementById(imageId+"view").src ="<?php echo $this->baseUrl("/")?>".split("admins/")[0] +"public/media/"+ dataObj.url;
											document.getElementById("data[<?php echo $iid?>]").value=dataObj.url;
										}
										$("#original_pro_button").css("display","none");
										$("#original_pro").css("display","none");
										$(".swfupload").css("display","none");
										$("#"+imageId+"view").css("display","block");
										$('#dialog').dialog('open');
										document.getElementById("thumbWindow").src=document.getElementById("thumbWindow").src+dataObj.id;
										document.getElementById("thumbWindow").src=document.getElementById("thumbWindow").src;
									},
									upload_complete_handler : function(){
									},
									
									button_placeholder_id : upload_target_id + "_button",
									button_width: 900,
									button_height: 40,
									button_text : button_text,
									button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12px;} .upload {font-size:13px;color:#3c969f;font-weight:bold;}',
									button_text_top_padding: 0,
									button_text_left_padding: 0,
									button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
									button_cursor: SWFUpload.CURSOR.HAND,
												
									flash_url :  "<?php echo $this->baseUrl("/media/swfupload.swf")?>",
						
									custom_settings : {
										upload_target : upload_target_id
									},	
								
									debug: false
								});
								return swfu;
							}
														</script>
								<div id="dialog" title="Make a Thumbnail">
								<p>
								<iframe id="thumbWindow" src="<?php echo $this->baseUrl("/IndexGallary/make-thumbnail/id/")?>" border="0" frameborder="0" height="320" style="overflow:hidden;" width="480">
								</iframe>
								</p>
								</div>
								<script type="text/javascript">
								<!--
								$().ready(function() {
									swfInit('original_pro','original','<span class="button"><span class="upload"><?php echo $this->__("Upload picture")?></span></span>');
									
								});
								$("#originalview").bind("click", function(){
									$('#dialog').dialog('open');
									document.getElementById("thumbWindow").src=document.getElementById("thumbWindow").src; 
								}); 
								
								//-->
								</script>
								<?php break;?>
						<?php case 'textarea':?>							
							<textarea rows="3" cols="12" 
								id="data-personal_information" 	
								onpropertychange="this.style.height=this.scrollHeight+'px';"
								oninput="this.style.height=this.scrollHeight+'px';"						
								class="input-text <?php echo isset($input['class'])?$input['class']:''?>"
								name="data[<?php echo $iid ?>]"><?php echo $this->escape($data->getData($iid)) ?></textarea>							
							<?php break;?>
						<?php case 'textarea disabled':?>							
							<textarea rows="3" cols="12" 
								id="data-personal_information" 	disabled="disabled"					
								class="input-text <?php echo isset($input['class'])?$input['class']:''?>"
								name="data[<?php echo $iid ?>]"><?php echo $this->escape($data->getData($iid)) ?></textarea>							
							<?php break;?>
						<?php case 'enable radio':?>
							<input type="radio" name="<?php echo $iid;?>" onclick="getRadioValue(1,'<?php echo $iid;?>')" <?php if($data->getData($iid)==1){?>checked="checked"<?php }?>>enable</input>
							<input type="radio"  name="<?php echo $iid;?>" onclick="getRadioValue(2,'<?php echo $iid;?>')" <?php if($data->getData($iid)==2){?>checked="checked"<?php }?>>disable</input>
							<input type="hidden" id="<?php echo $iid;?>" name=data[<?php echo $iid;?>] value="<?php echo $data->getData($iid);?>"></input>
							<?php break;?>
						<?php case 'input hidden':?>
							<input type="hidden" name="data[<?php echo $iid?>]" value="<?php echo $data->getData($iid)?>" />
							<?php break;?>
						<?php case 'ckedit-textarea':?>							
							<textarea class="ckeditor" cols="80" id="editor1" name="data[<?php echo $iid ?>]" rows="10"><?php echo $this->escape($data->getData($iid)) ?></textarea>							
							<?php break;?>
						<?php case 'richedit':?>		
							<textarea name="data[<?php echo $iid ?>]" cols="80" rows="10" class="wysiwyg"><?php echo $this->escape($data->getData($iid)) ?></textarea>
						<?php break;?>
						<?php case 'password':?>
							<input type="password" class="input-text <?php echo isset($input['class'])?$input['class']:''?>" name="data[<?php echo $iid?>]"
								id="data-<?php echo $iid?>" value="<?php echo $this->escape($data->getData($iid))?>" />
							<?php break;?>
						<?php case 'customer':?>
							<?php echo $input["code"]; ?>
							<?php break;?>
						<?php case 'date':?>
							<input type="text" style="width:100px;" id="data-<?php echo $iid?>"
							 class="input-text <?php echo isset($input['class'])?$input['class']:''?>" readonly="readonly" 							
							 name="data[<?php echo $iid?>]" value="<?php 
							 if($data->getData($iid))
							 echo $this->escape($data->getData($iid)->toString("MM/dd/YYYY"))?>" />
							 <img id="img-<?php echo $iid?>" align="middle" src="<?php echo $this->baseUrl("media/images/calendar_new.png")?>" />
							 <script type="text/javascript">
							 $("#data-<?php echo $iid?>").datepicker();
							 $("#img-<?php echo $iid?>").click(function(){
								 $("#data-<?php echo $iid?>").trigger("focus");
							});
							 </script>
							<?php break;?>
						<?php case 'date-time':?>
							<input type="text" style="width:100px;" id="data-<?php echo $iid?>"
							 class="input-text <?php echo isset($input['class'])?$input['class']:''?>" readonly="readonly" 							
							 name="data[<?php echo $iid?>]" value="<?php 
							 if($data->getData($iid))
							 echo $this->escape($data->getData($iid)->toString("MM/dd/YYYY"))?>" />
							 <label style="width:50px" for="event_start_date-hour"> Hour: </label>
							 <select class="input-select required valid" id="data-<?php echo $iid?>-hour" name="data[<?php echo $iid?>-hour]">
							 <?php if(!$data->getData($iid.'-hour')) :?>
							 <option label="Hour" value="">Hour</option>
							 <?php endif;?>
							 <?php for($i=0;$i<=23;$i++) :
							    if($i<10):
							    	if($i==(int)$data->getData($iid.'-hour')):
							 ?>
							 			<option selected="selected" label="0<?php echo $i?>" value="0<?php echo $i?>">0<?php echo $i?></option>
							 		<?php else:?>
							    		<option label="0<?php echo $i?>" value="0<?php echo $i?>">0<?php echo $i?></option>
							    	<?php endif;?>
							 <?php else:
							 		if($i==(int)$data->getData($iid.'-hour')):
							 ?>
							 			<option selected="selected" label="<?php echo $i?>" value="<?php echo $i?>"><?php echo $i?></option>
							 		<?php else :?>
							 			<option label="<?php echo $i?>" value="<?php echo $i?>"><?php echo $i?></option>
							 		<?php endif;?>
							 <?php endif;?>
							 <?php endfor;?>
							 </select>
							 <label style="width:50px" for="event_start_date-min"> Minute: </label>
							 <select class="input-select required valid" id="data-<?php echo $iid?>-min" name="data[<?php echo $iid?>-min]">
							 <?php if(!$data->getData($iid.'-min')) :?>
							 <option label="Minute" value="">Minute</option>
							 <?php endif;?>
							 <?php for($i=0;$i<=60;$i++) :
							 	if($i<10):
							 		if($i==(int)$data->getData($iid.'-min')):
							 ?>
							    		<option selected="selected" label="0<?php echo $i?>" value="0<?php echo $i?>">0<?php echo $i?></option>
							 		<?php else:?>
							    		<option label="0<?php echo $i?>" value="0<?php echo $i?>">0<?php echo $i?></option>
							    	<?php endif;?>
							 <?php else:
							 		if($i==(int)$data->getData($iid.'-min')):
							 ?>
							 			<option selected="selected" label="<?php echo $i?>" value="<?php echo $i?>"><?php echo $i?></option>
							 		<?php else :?>
							 			<option label="<?php echo $i?>" value="<?php echo $i?>"><?php echo $i?></option>
							 		<?php endif;?>
							 <?php endif;?>
							 <?php endfor;?>
							 </select>
							 <!-- select class="input-select required valid" id="data-<?php echo $iid?>-second" name="data[<?php echo $iid?>-second]">
							 <?php if(!$data->getData($iid.'-second')) :?>
							 <option label="Second" value="">Second</option>
							 <?php endif;?>
							 <?php for($i=0;$i<=60;$i++) :
							 	if($i<10):
							 		if($i==(int)$data->getData($iid.'-second')):
							 ?>
							    		<option selected="selected" label="0<?php echo $i?>" value="0<?php echo $i?>">0<?php echo $i?></option>
							 		<?php else:?>
							    		<option label="0<?php echo $i?>" value="0<?php echo $i?>">0<?php echo $i?></option>
							    	<?php endif;?>
							 <?php else:
							 		if($i==(int)$data->getData($iid.'-second')):
							 ?>
							 			<option selected="selected" label="<?php echo $i?>" value="<?php echo $i?>"><?php echo $i?></option>
							 		<?php else :?>
							 			<option label="<?php echo $i?>" value="<?php echo $i?>"><?php echo $i?></option>
							 		<?php endif;?>
							 <?php endif;?>
							 <?php endfor;?>
							 </select-->
							 <img id="img-<?php echo $iid?>" align="middle" src="<?php echo $this->baseUrl("media/images/calendar_new.png")?>" />
							 <script type="text/javascript">
							 $("#data-<?php echo $iid?>").datepicker();
							 $("#img-<?php echo $iid?>").click(function(){
								 $("#data-<?php echo $iid?>").trigger("focus");
							});
							 </script>
							<?php break;?>
						<?php case 'input disable':?>
							<input style="float:left;" disabled="disabled" type="text" class="input-text <?php echo isset($input['class'])?$input['class']:''?>" name="data[<?php echo $iid?>]"
								id="data-<?php echo $iid?>" value="<?php echo $this->escape($data->getData($iid))?>" />
								
								<?php if (isset($input['unit'])):?>
   								<span  class="form-unit"><?php echo $input['unit'];?></span>
   								<?php endif;?>
							<?php break;?>
						<?php case 'link':?>
							<a style="float:left;"  onclick="window.open(this.href,'win2',''); return false;"href="<?php echo $this->escape($data->getData($iid))?>" /><?php echo $this->escape($data->getData($iid))?></a>
							<?php break;?>
						<?php default:?>
							<input style="float:left;" type="text" class="input-text <?php echo isset($input['class'])?$input['class']:''?>" name="data[<?php echo $iid?>]"
								id="data-<?php echo $iid?>" value="<?php echo $this->escape($data->getData($iid))?>" />
								
								<?php if (isset($input['unit'])):?>
   								<span  class="form-unit"><?php echo $input['unit'];?></span>
   								<?php endif;?>
								
						<?php endswitch;?>
						</td>
						<td class="description"><?php echo isset($input['description'])?$input['description']:''?></td>
					</tr>
				<?php endforeach;?>
				</table>
				</div>
			</div>
		</div>
	</div>
	<div style="clear:both;"></div>
	<?php endforeach;?>
</div>

<?php if (isset($this->tree)):?>
<div id="role-tree" style="diaplay:none;" class="content-wrapper">
<ul id="role-tree-ul" >
  <?php foreach($this->tree as $scope => $scopeArray):?>
      <li>
      <input id="<?php echo $scope?>" name="treefield" <?php if ($this->isAllowed($acl,$data->getRoleName(),$scope)):?>checked="checked"<?php endif;?> onclick="selectLevelAll('<?php echo  $scope?>')" type="checkbox"><?php echo $scope;?>
	  <ul>
	  <?php foreach($scopeArray as $module => $moduleArray):?>
		   <li><input id="<?php echo $scope."-".$module?>" name="treefield" <?php if ($this->isAllowed($acl,$data->getRoleName(), $scope."-".$module)):?>checked="checked"<?php endif;?> value="<?php echo $module?>" onclick="selectLevelAll('<?php echo  $scope."-".$module?>')" type="checkbox"><span><?php echo $module;?></span>
		   <ul>
		   <?php foreach($moduleArray as $controllor => $controllorArray):?>
		   <li><input id="<?php echo $scope."-".$module."-".$controllor?>" name="treefield" <?php if ($this->isAllowed($acl,$data->getRoleName(), $scope."-".$module."-".$controllor)):?>checked="checked"<?php endif;?> value="<?php echo $controllor?>" onclick="selectLevelAll('<?php echo  $scope."-".$module."-".$controllor?>')" type="checkbox"><span><?php echo $controllor;?></span>
		   <ul>
			   <?php foreach($controllorArray as $action => $actionArray):?>
			      <li>
			      <input id="<?php echo $scope."-".$module."-".$controllor."-".$action?>" 
			                  <?php if ($this->isAllowed($acl,$data->getRoleName(), $scope."-".$module."-".$controllor."-".$action)):?>
			                  checked="checked"
			                  <?php elseif($action == 'index' && $this->isAllowed($acl,$data->getRoleName(), $scope."-".$module."-".$controllor)):?>
			                  checked="checked"
			                  <?php endif;?> value="<?php echo $controllor?>" onclick="selectLevelAll('<?php echo $scope."-".$module."-".$controllor."-".$action?>')" value="<?php echo  $scope."-".$module."-".$controllor."-".$action?>" name="treefield" onclick="selectLevelAll('<?php echo  $scope."-".$module."-".$controllor."-".$action?>')"  type="checkbox"><span><?php echo $action;?></span>
			      <ul>
			      <?php foreach($actionArray as  $param):?>
			      <li><input id="<?php echo  $scope."-".$module."-".$controllor."-".$action."-".$param?>" <?php if ($this->isAllowed($acl,$data->getRoleName(), $scope."-".$module."-".$controllor."-".$action."-".$param)):?>checked="checked"<?php endif;?> value="<?php echo $controllor?>" value="<?php echo $param?>" name="treefield" type="checkbox"><span><?php echo $param;?></span></li>
			      <?php endforeach; ?>
			      </ul>
			      </li>
			   <?php endforeach; ?>
			   </ul>
			   </li>
		   <?php endforeach; ?>
		   </ul>
		   </li>
	  <?php endforeach; ?>
	  </ul>
	  </li>
  <?php endforeach; ?>
</ul>
</div>
<input type="hidden" name="tree" id="jsonTree" value="">
<?php endif;?>

</fieldset>	
</form>
<script>

function checkForm(){
	<?php if (isset($this->tree)):?>
   	checkTreeValue();
	<?php endif;?>
	$('#<?php echo $formId?>').submit()
}

function checkInfo(value){
	$("#check").val(value);
	$('#<?php echo $formId?>').submit()
}

function getRadioValue(value,inputId) {
	$("#"+inputId).val(value);
}

function checkTreeValue(){
	var checkboxes=$("input[name='treefield']");
	var jsonStr='';
	for(var i=0;i<checkboxes.length;i++){
		jsonStr=jsonStr+checkboxes[i].id+","+checkboxes[i].checked+"|";
	}
	$("#jsonTree").attr("value",jsonStr);
}
function selectLevelAll(id){
	if($("#"+id).attr("checked")) {
		$("input[id*='"+id+"']").attr("checked", true); 
	} else {
		$("input[id*='"+id+"']").attr("checked", false);
	} 
}

function changeValue(url) {
	var selectVal = $('#add_type').val();
	window.location.href=url+'/information/information/add/selectType/'+selectVal;
}

</script>	


